import Teacher from "./../../components/teacher";

import Header from "./../../components/Header";
import {Link} from "react-router";
import {connect} from "react-redux";
import NoData from "./../../components/nodata";
import Search from "./../../components/search";
import Panel from "./../../elements/Panel";
import Pagination from "./../../components/Pagination/";
import {Config, Fetch, Lang} from "./../../libs/";
import {SUBJECT, PAGE_SUBJECT} from "./../../actions/subject";
import {fetch, fetchUser} from "../../actions";
import {URL, md5Url} from "./../../libs/Url";

const News = React.createClass({
    componentDidMount() {
        const {dispatch} = this.props;
        //
        // dispatch(fetchUser()); //获取登录用户信息
        Fetch(URL.Get_USER_CLASS)
            .then(res=> {
                dispatch(fetch({url: URL.CLASS_TEACHER_FIND, classids: res.list[res.list.length - 1].classid}));
            })
            .catch(e=> {
                console.log(e)
            })

    },

    render(){
        const self = this;
        const {user} = this.props;
        const data = self.props[md5Url.CLASS_TEACHER_FIND] || {};
        (!data.list && (data.list = []));
        return (
            <Panel>
                <Header>{Lang.menus.CLASS_INFO_TEACHER}</Header>
                <div className="classTeacher">
                    {data.list.map((item, index)=> {
                        return <Teacher key={index} {...item}></Teacher>
                    })}
                </div>

            </Panel>
        )
    }
});
function select(state) {
    return {
        user: state.user.user,
        [md5Url.CLASS_TEACHER_FIND]: state.fetchBySubject[md5Url.CLASS_TEACHER_FIND],
        [PAGE_SUBJECT.CLASS_TEACHER]: state.pageBySubject[PAGE_SUBJECT.CLASS_TEACHER],
    }
}
export default connect(select)(News)
